/* 
 * File:   LinkParser.cc
 * Author: marcel
 * 
 * Created on April 5, 2011, 1:32 PM
 */

#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <iostream>
#include <string>
#include "LinkParser.h"
#include "Hoster.h"

LinkParser::LinkParser(Hoster& hoster) {
    hoster = hoster;
}

LinkParser::LinkParser(const LinkParser& orig) {
}

LinkParser::~LinkParser() {
}

/**
 * Method that validates a given url 
 * @param url Url in form http://...
 */
void LinkParser::addLink(std::string url) {
    boost::regex re("(ftp|http|https)://(\\w+.)*(\\w*)/([\\w\\d]+/{0,1})+");

    BOOST_FOREACH(Hoster hoster, this->hoster) {
        try {
            if (boost::regex_match(url, re)) {

            }
        } catch (boost::regex_error& e) {
            cerr << "The regexp " << re << " is invalid!" << endl;
            throw (e);
        }
    }


}
